<?php
////////////////////////////////////////////////////////////////////////////////////////
// Purpose: Get data from url and change the contents of the #gallery div
////////////////////////////////////////////////////////////////////////////////////////

require_once '../cmsadmin/model/includes/Image.class.php';
require_once '../cmsadmin/model/includes/ImageGallery.class.php';

session_start();

$galleryName = $_GET['q'];
$gallery;
$xml = new DOMDocument();

if (!isset($_SESSION['initiated'])) {
    session_regenerate_id();
    $_SESSION['initiated'] = true;
}

if(!issset($_SESSION[ $galleryName ])) {

    $gallery = new ImageGallery();
    $_SESSION[ $galleryName ] = $gallery;

}else {

    $gallery = $_SESSION[ $galleryName ];
    
}

foreach($gallery->getImages() as $image){

    echo '<img href="../cmsadmin/view/images/"'.$gallery->getTitle().'/'.$image->getName().'" alt="'.$image->getDescription().'" title="'.$image->getDescription().'"/>'."/n";

}

?>